﻿namespace ctolua.Models
{
    /// <summary>
    /// 镜头
    /// </summary>
    public class MCamera
    {
        /// <summary>
        /// 镜头对象
        /// </summary>
        public Camera camera { get; set; }
        /// <summary>
        /// 点
        /// </summary>
        public Point focus_point;
        /// <summary>
        /// 焦距
        /// </summary>
        public double? dis;
        /// <summary>
        /// 焦点高度
        /// </summary>
        public double? focus_y;
        /// <summary>
        /// 偏航角
        /// </summary>
        public double? yaw;
        /// <summary>
        /// 服仰角
        /// </summary>
        public double? pitch;
        /// <summary>
        /// 视距
        /// </summary>
        public double? fov;
        /// <summary>
        /// 创建镜头
        /// </summary>
        /// <param name="focus_point ">  点   </param>
        /// <param name="dis ">  焦距   </param>
        /// <param name="focus_y ">  焦点高度   None</param>
        /// <param name="yaw ">  偏航角   None</param>
        /// <param name="pitch ">  服仰角   None</param>
        /// <param name="fov ">  视距   None</param>
        public MCamera(Point focus_point, double? dis, double? focus_y, double? yaw, double? pitch, double? fov)
        {
            this.focus_point = focus_point;
            this.dis = dis;
            this.focus_y = focus_y;
            this.yaw = yaw;
            this.pitch = pitch;
            this.fov = fov;
            this.camera = (dynamic)game_api.add_camera_conf(this.focus_point, this.dis, this.focus_y, this.yaw, this.pitch, this.pitch);

        }

        /// <summary>
        /// 应用镜头配置
        /// </summary>
        /// <param name="role ">  玩家   </param>
        /// <param name="duration ">  过渡时间   </param>
        /// <param name="slope_mode ">  镜头移动类型   0</param>
        public void apply_camera_conf(Role role, double? duration, int? slope_mode) => game_api.apply_camera_conf(role, this.camera, duration, slope_mode);

        /// <summary>
        /// 镜头是否存在
        /// </summary>
        /// <param name="camera ">  镜头   </param>
        /// <returns>是否存在</returns>
        public bool? is_null => game_api.camera_is_exist(this.camera);

        /// <summary>
        /// 本地镜头在跟随状态
        /// </summary>
        /// <returns>是否跟随</returns>
        public static bool? is_following_target => game_api.camera_is_following_target();
        /// <summary>
        /// 本地玩家摄像机朝向
        /// </summary>
        /// <returns>摄像机朝向</returns>
        public static MPoint get_local_player_camera_direction => new MPoint(game_api.get_local_player_camera_direction());
        /// <summary>
        /// 本地玩家摄像机中心射线检测
        /// </summary>
        /// <returns>交点</returns>
        public static MPoint get_local_player_camera_center_raycast => new MPoint(game_api.get_local_player_camera_center_raycast());
    }
}
